﻿CREATE TABLE [dbo].[BillOrder]
(
	[Id] INT NOT NULL PRIMARY KEY IDENTITY, 
	[BkMemberId] BIGINT NULL, 
    [WxUserId] BIGINT NULL, 
    [CardType] NVARCHAR(50) NULL, 
    [CardNo] NVARCHAR(50) NULL, 
	[CardName] NVARCHAR(50) NULL,
    [ClinicNo] NVARCHAR(50) NULL, 
    [PrescMoney] DECIMAL(18, 2) NULL, 
	[YiBaoStatus] INT NULL,
	[YibaoMoney] DECIMAL(18, 2) NULL, 
	[YiBaoJydjh] NVARCHAR(50) NULL,
	[YiBaoIndiId] NVARCHAR(50) NULL,
	[PersonalMoney] DECIMAL(18, 2) NULL, 
    [OrderDept] NVARCHAR(50) NULL, 
    [OrderDate] NVARCHAR(50) NULL, 
    [Remark] NTEXT NULL, 
    [OrderStatus] INT NOT NULL, 
    [PayState] NVARCHAR(50) NULL, 
    [CreateTime] DATETIME NULL, 
    [PayTime] DATETIME NULL, 
    [FetchTime] DATETIME NULL, 
    [RefundTime] DATETIME NULL, 
    [NextCheckTime] DATETIME NULL, 
    [OrderStatusOnSetCheck] INT NULL, 
    [CheckReserved] NVARCHAR(50) NULL, 
    [WxTransactionId] NVARCHAR(50) NULL, 
    [WxRefundId] NVARCHAR(50) NULL, 
    [OrderNo] NVARCHAR(50) NULL
)

GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'主键，自增长',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'Id'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'WxUser.Id',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = 'WxUserId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'卡类型: 0-诊疗卡1-健康卡 2-市民卡',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'CardType'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'患者信息卡卡号',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'CardNo'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'就诊流水号',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'ClinicNo'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'缴费单开单费用',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'PrescMoney'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'缴费单开单科室',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'OrderDept'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'缴费单开单时间',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'OrderDate'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'备注',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'Remark'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'支付状态：0未支付 1支付中 2支付成功 3支付失败 4退款中 5退款成功 6退款失败 7缴费中 8缴费成功 9缴费失败',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'OrderStatus'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'支付状态:0-未付款,1-已付款,2-退款中,3-已退款',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'PayState'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'订单创建时间',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'CreateTime'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'支付成功时间，支付成功后微信返回',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'PayTime'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'缴费成功时间',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'FetchTime'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'退款成功时间',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'RefundTime'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'系统下次检查时间',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'NextCheckTime'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'设置系统下次检查时间时的订单状态',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'OrderStatusOnSetCheck'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'系统检查预留字段',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'CheckReserved'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'微信支付交易号，支付成功后微信返回',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'WxTransactionId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'微信支付退款单号，退款成功后微信返回',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'WxRefundId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'订单号',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'OrderNo'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'医保费用',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'YibaoMoney'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'自费费用',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = 'PersonalMoney'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'BkMember.Id',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'BkMemberId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'医保使用状态，null，0：未使用医保，1：使用了医保，2：取消了医保',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = 'YiBaoStatus'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'医保就医登记号',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'YiBaoJydjh'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'个人医保号',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'YiBaoIndiId'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'卡主姓名',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'CardName'